package com.mux.excelutil;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

//import com.nielsenccdata.loa.dao.StoreDao;
 
/**
 * 批量上传 store master excel
 * @author devin.chen
 *
 */
public class BatchStoreExcel extends BatchUploadExcelUtil {
	
	private static final Logger logger=LoggerFactory.getLogger(BatchStoreExcel.class);
//	private StoreDao storeDao;
    private List msg = new ArrayList();
    private List<List<String>> lists = new ArrayList<List<String>>();
    public List getMsg() {
        return msg;
    }
 
    
    public void optRows(int sheetIndex,int curRow, List<String> rowlist) throws SQLException {
       
    	if(rowlist!=null&&rowlist.size()!=0){
    		if(lists.size()==5000){
    			 insertBatchData();
    			 lists.clear();
    	    }
            List list = new ArrayList();
            list.addAll(rowlist);
            lists.add(list);
        }
    }

    public int insertBatchData(){
		logger.info("开始insert temp_store");
		String addSql = "INSERT INTO temp_store  VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
		//批量添加
	//	int addNum = storeDao.insertCommon(addSql, lists);
		//logger.info("addNum:"+addNum);
	/*	
		for(int i=0;i<lists.size();i++){
			try {
				oreDao.insertStoreMaster(lists.get(i));
			} catch (Exception e) {
				logger.error("插入error:"+lists.get(i).toString(),e);
				throw  new RuntimeException(e);
				//e.printStackTrace();
			}
		}*/
		return 0;
    }
    public static void main(String[] args) throws Exception {
      //  System.out.println("start="+DateUtil.fmtDateQ(new Date()));
        BatchStoreExcel howto = new BatchStoreExcel();
        howto.processOneSheet("C://Users//Devin.chen//Desktop//sheet_5_10w.xlsx", 1);
        System.out.println("行数："+howto.getMsg().size());
     //   System.out.println("end="+DateUtil.fmtDateQ(new Date()));
    }

	/*public void setStoreDao(StoreDao storeDao) {
		this.storeDao = storeDao;
	}*/
    public List<List<String>> getLists() {
		return lists;
	}


	public void setMsg(List msg) {
        this.msg = msg;
    }
 

    
}
